<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script>
    function checkUser(){
      var name = document.getElementById("username").value;
      // 定义规则
      var regExp = /^[0-9]{3-6}$/;
      if (regExp.test(uname)) {
        alert("OK")
      } else {
        alert("请重新输入")
      }
    }
  </script>
</head>
<body>
<input type="text" id="username" onblur="checkUser()"><br>
<input type="password" id="pwd">
<button>注册</button>
</body>
</html>